#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

static int a=100;

int main(int argc,char* const argv){

    pid_t pid=-1;
    pid = fork();
    if(pid < 0){
        perror("fork err");
        return -1;
    }else if(pid == 0){
        sleep(5);
        exit(0);
    }else{
        while(1){
            int ret=waitpid(pid,0,WNOHANG);
            if(ret > 0){
                break;
            }else if(ret < 0){
                printf("err");
            }
            sleep(1);
        }
    }
    

    return 0;
}